package upmc.fr.android.rss.comparator;

import upmc.fr.android.model.RSSArticle;

public class RSSArticleDateComparator implements RSSArticleComparator
{
	private boolean ascending = true;
	
	public void setAscending(boolean ascending)
	{
		this.ascending = ascending;
	}
	
	@Override
	public int compare(RSSArticle o1, RSSArticle o2) 
	{
		if(ascending)
			return o1.getDate().compareTo(o2.getDate());
	
		switch(o1.getDate().compareTo(o2.getDate()))
		{
			case -1 : return 1;
			case 0 : return 0;
			case 1 : return -1;
			default : return 0;
		}		
	}
}
